<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>&lt;GDate&gt;: </title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.2">
<link rel="home" href="index.html" title="">
<link rel="up" href="ch01.html" title="GLib">
<link rel="prev" href="re08.html" title="&lt;%GLibConvertError&gt;">
<link rel="next" href="re10.html" title="&lt;%GLibDateDMY&gt;">
<meta name="generator" content="GTK-Doc V1.33.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><img src="up-insensitive.png" width="16" height="16" border="0"></td>
<td><a accesskey="p" href="re08.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="re10.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="id-1.1.10"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2>&lt;GDate&gt;</h2>
<p>&lt;GDate&gt;</p>
</div>
<div class="refsect1">
<a name="id-1.1.10.2"></a><h2>Description</h2>
<p>Represents a day between January 1, Year 1 and a few thousand years in
the future. None of its members should be accessed directly.
</p>
<p>If the <span class="type">GDate</span>-struct is obtained from <code class="function">g_date_new()</code>, it will be safe
to mutate but invalid and thus not safe for calendrical computations.
</p>
<p>If it's declared on the stack, it will contain garbage so must be
initialized with <code class="function">g_date_clear()</code>. <code class="function">g_date_clear()</code> makes the date invalid
but safe. An invalid date doesn't represent a day, it's "empty." A date
becomes valid after you set it to a Julian day or you set a day, month,
and year.</p>
</div>
<div class="refsect1">
<a name="id-1.1.10.3"></a><h2>Functions</h2>
<div class="refsect2">
<a name="id-1.1.10.3.2"></a><h3>add-days</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:add-days self n-days))
</pre></div>
<p>Increments a date some number of days.
To move forward by weeks, add weeks*7 days.
The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.2.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to increment</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>n_days</p></td>
<td class="parameter_description">
<p>number of days to move the date forward</p>
<p>Passed as <code class="code">n-days</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.3"></a><h3>add-months</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:add-months self n-months))
</pre></div>
<p>Increments a date by some number of months.
If the day of the month is greater than 28,
this routine may change the day of the month
(because the destination month may not have
the current day in it). The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.3.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to increment</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>n_months</p></td>
<td class="parameter_description">
<p>number of months to move forward</p>
<p>Passed as <code class="code">n-months</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.4"></a><h3>add-years</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:add-years self n-years))
</pre></div>
<p>Increments a date by some number of years.
If the date is February 29, and the destination
year is not a leap year, the date will be changed
to February 28. The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.4.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to increment</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>n_years</p></td>
<td class="parameter_description">
<p>number of years to move forward</p>
<p>Passed as <code class="code">n-years</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.5"></a><h3>clamp</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:clamp self min-date max-date))
</pre></div>
<p>If <em class="parameter"><code>date</code></em> is prior to <em class="parameter"><code>min_date</code></em>, sets <em class="parameter"><code>date</code></em> equal to <em class="parameter"><code>min_date</code></em>.
If <em class="parameter"><code>date</code></em> falls after <em class="parameter"><code>max_date</code></em>, sets <em class="parameter"><code>date</code></em> equal to <em class="parameter"><code>max_date</code></em>.
Otherwise, <em class="parameter"><code>date</code></em> is unchanged.
Either of <em class="parameter"><code>min_date</code></em> and <em class="parameter"><code>max_date</code></em> may be <code class="constant">NULL</code>.
All non-<code class="constant">NULL</code> dates must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.5.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to clamp</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>min_date</p></td>
<td class="parameter_description">
<p>minimum accepted value for <em class="parameter"><code>date</code></em></p>
<p>Passed as <code class="code">min-date</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>max_date</p></td>
<td class="parameter_description">
<p>maximum accepted value for <em class="parameter"><code>date</code></em></p>
<p>Passed as <code class="code">max-date</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.6"></a><h3>clear</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:clear self n-dates))
</pre></div>
<p>Initializes one or more <span class="type">GDate</span> structs to a safe but invalid
state. The cleared dates will not represent an existing date, but will
not contain garbage. Useful to init a date declared on the stack.
Validity can be tested with <code class="function">g_date_valid()</code>.</p>
<div class="refsect3">
<a name="id-1.1.10.3.6.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>pointer to one or more dates to clear</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>n_dates</p></td>
<td class="parameter_description">
<p>number of dates to clear</p>
<p>Passed as <code class="code">n-dates</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.7"></a><h3>compare</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:compare self rhs))
</pre></div>
<p><code class="function">qsort()</code>-style comparison function for dates.
Both dates must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.7.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>lhs</p></td>
<td class="parameter_description">
<p>first date to compare</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>rhs</p></td>
<td class="parameter_description">
<p>second date to compare</p>
<p>Passed as <code class="code">rhs</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.8"></a><h3>copy</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:copy self))
</pre></div>
<p>Copies a GDate to a newly-allocated GDate. If the input was invalid
(as determined by <code class="function">g_date_valid()</code>), the invalid state will be copied
as is into the new object.</p>
<div class="refsect3">
<a name="id-1.1.10.3.8.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to copy</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.9"></a><h3>days-between</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:days-between self date2))
</pre></div>
<p>Computes the number of days between two dates.
If <em class="parameter"><code>date2</code></em> is prior to <em class="parameter"><code>date1</code></em>, the returned value is negative.
Both dates must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.9.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date1</p></td>
<td class="parameter_description">
<p>the first date</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>date2</p></td>
<td class="parameter_description">
<p>the second date</p>
<p>Passed as <code class="code">date2</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.10"></a><h3>free</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:free self))
</pre></div>
<p>Frees a <span class="type">GDate</span> returned from <code class="function">g_date_new()</code>.</p>
<div class="refsect3">
<a name="id-1.1.10.3.10.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to free</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.11"></a><h3>get-day</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-day self))
</pre></div>
<p>Returns the day of the month. The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.11.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to extract the day of the month from</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.12"></a><h3>get-day-of-year</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-day-of-year self))
</pre></div>
<p>Returns the day of the year, where Jan 1 is the first day of the
year. The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.12.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to extract day of year from</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.13"></a><h3>get-iso8601-week-of-year</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-iso8601-week-of-year self))
</pre></div>
<p>Returns the week of the year, where weeks are interpreted according
to ISO 8601.</p>
<div class="refsect3">
<a name="id-1.1.10.3.13.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a valid <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.14"></a><h3>get-julian</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-julian self))
</pre></div>
<p>Returns the Julian day or "serial number" of the <span class="type">GDate</span>. The
Julian day is simply the number of days since January 1, Year 1; i.e.,
January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
etc. The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.14.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to extract the Julian day from</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.15"></a><h3>get-monday-week-of-year</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-monday-week-of-year self))
</pre></div>
<p>Returns the week of the year, where weeks are understood to start on
Monday. If the date is before the first Monday of the year, return 0.
The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.15.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.16"></a><h3>get-month</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-month self))
</pre></div>
<p>Returns the month of the year. The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.16.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to get the month from</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.17"></a><h3>get-sunday-week-of-year</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-sunday-week-of-year self))
</pre></div>
<p>Returns the week of the year during which this date falls, if
weeks are understood to begin on Sunday. The date must be valid.
Can return 0 if the day is before the first Sunday of the year.</p>
<div class="refsect3">
<a name="id-1.1.10.3.17.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.18"></a><h3>get-weekday</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-weekday self))
</pre></div>
<p>Returns the day of the week for a <span class="type">GDate</span>. The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.18.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.19"></a><h3>get-year</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-year self))
</pre></div>
<p>Returns the year of a <span class="type">GDate</span>. The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.19.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.20"></a><h3>is-first-of-month?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:is-first-of-month? self))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the date is on the first of a month.
The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.20.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to check</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.21"></a><h3>is-last-of-month?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:is-last-of-month? self))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the date is the last day of the month.
The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.21.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to check</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.22"></a><h3>order</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:order self date2))
</pre></div>
<p>Checks if <em class="parameter"><code>date1</code></em> is less than or equal to <em class="parameter"><code>date2</code></em>,
and swap the values if this is not the case.</p>
<div class="refsect3">
<a name="id-1.1.10.3.22.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date1</p></td>
<td class="parameter_description">
<p>the first date</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>date2</p></td>
<td class="parameter_description">
<p>the second date</p>
<p>Passed as <code class="code">date2</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.23"></a><h3>set-day</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:set-day self day))
</pre></div>
<p>Sets the day of the month for a <span class="type">GDate</span>. If the resulting
day-month-year triplet is invalid, the date will be invalid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.23.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>day</p></td>
<td class="parameter_description">
<p>day to set</p>
<p>Passed as <code class="code">day</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.24"></a><h3>set-dmy</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:set-dmy self day month y))
</pre></div>
<p>Sets the value of a <span class="type">GDate</span> from a day, month, and year.
The day-month-year triplet must be valid; if you aren't
sure it is, call <code class="function">g_date_valid_dmy()</code> to check before you
set it.</p>
<div class="refsect3">
<a name="id-1.1.10.3.24.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>day</p></td>
<td class="parameter_description">
<p>day</p>
<p>Passed as <code class="code">day</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>month</p></td>
<td class="parameter_description">
<p>month</p>
<p>Passed as <code class="code">month</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>y</p></td>
<td class="parameter_description">
<p>year</p>
<p>Passed as <code class="code">y</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.25"></a><h3>set-julian</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:set-julian self julian-date))
</pre></div>
<p>Sets the value of a <span class="type">GDate</span> from a Julian day number.</p>
<div class="refsect3">
<a name="id-1.1.10.3.25.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>julian_date</p></td>
<td class="parameter_description">
<p>Julian day number (days since January 1, Year 1)</p>
<p>Passed as <code class="code">julian-date</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.26"></a><h3>set-month</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:set-month self month))
</pre></div>
<p>Sets the month of the year for a <span class="type">GDate</span>.  If the resulting
day-month-year triplet is invalid, the date will be invalid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.26.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>month</p></td>
<td class="parameter_description">
<p>month to set</p>
<p>Passed as <code class="code">month</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.27"></a><h3>set-parse</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:set-parse self str))
</pre></div>
<p>Parses a user-inputted string <em class="parameter"><code>str</code></em>, and try to figure out what date it
represents, taking the [current locale][setlocale] into account. If the
string is successfully parsed, the date will be valid after the call.
Otherwise, it will be invalid. You should check using <code class="function">g_date_valid()</code>
to see whether the parsing succeeded.
</p>
<p>This function is not appropriate for file formats and the like; it
isn't very precise, and its exact behavior varies with the locale.
It's intended to be a heuristic routine that guesses what the user
means by a given string (and it does work pretty well in that
capacity).</p>
<div class="refsect3">
<a name="id-1.1.10.3.27.5"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to fill in</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>str</p></td>
<td class="parameter_description">
<p>string to parse</p>
<p>Passed as <code class="code">str</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.28"></a><h3>set-time</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:set-time self time-))
</pre></div>
<p>Sets the value of a date from a <span class="type">GTime</span> value.
The time to date conversion is done using the user's current timezone.</p>
<div class="refsect3">
<a name="id-1.1.10.3.28.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span>.</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>time_</p></td>
<td class="parameter_description">
<p><span class="type">GTime</span> value to set.</p>
<p>Passed as <code class="code">time-</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.29"></a><h3>set-time-t</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:set-time-t self timet))
</pre></div>
<p>Sets the value of a date to the date corresponding to a time
specified as a time_t. The time to date conversion is done using
the user's current timezone.
</p>
<p>To set the value of a date to the current day, you could write:
</p>
<div class="informalexample"><pre class="programlisting">
 time_t now = time (NULL);
 if (now == (time_t) -1)
   // handle the error
 g_date_set_time_t (date, now);
</pre></div>
<div class="refsect3">
<a name="id-1.1.10.3.29.5"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>timet</p></td>
<td class="parameter_description">
<p>time_t value to set</p>
<p>Passed as <code class="code">timet</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.30"></a><h3>set-year</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:set-year self year))
</pre></div>
<p>Sets the year for a <span class="type">GDate</span>. If the resulting day-month-year
triplet is invalid, the date will be invalid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.30.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span></p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>year</p></td>
<td class="parameter_description">
<p>year to set</p>
<p>Passed as <code class="code">year</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.31"></a><h3>subtract-days</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:subtract-days self n-days))
</pre></div>
<p>Moves a date some number of days into the past.
To move by weeks, just move by weeks*7 days.
The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.31.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to decrement</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>n_days</p></td>
<td class="parameter_description">
<p>number of days to move</p>
<p>Passed as <code class="code">n-days</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.32"></a><h3>subtract-months</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:subtract-months self n-months))
</pre></div>
<p>Moves a date some number of months into the past.
If the current day of the month doesn't exist in
the destination month, the day of the month
may change. The date must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.32.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to decrement</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>n_months</p></td>
<td class="parameter_description">
<p>number of months to move</p>
<p>Passed as <code class="code">n-months</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.33"></a><h3>subtract-years</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:subtract-years self n-years))
</pre></div>
<p>Moves a date some number of years into the past.
If the current day doesn't exist in the destination
year (i.e. it's February 29 and you move to a non-leap-year)
then the day is changed to February 29. The date
must be valid.</p>
<div class="refsect3">
<a name="id-1.1.10.3.33.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to decrement</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>n_years</p></td>
<td class="parameter_description">
<p>number of years to move</p>
<p>Passed as <code class="code">n-years</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.34"></a><h3>to-struct-tm</h3>
<div class="informalexample"><pre class="programlisting">(define-values () (date:to-struct-tm self tm))
</pre></div>
<p>Fills in the date-related bits of a struct tm using the <em class="parameter"><code>date</code></em> value.
Initializes the non-date parts with something safe but meaningless.</p>
<div class="refsect3">
<a name="id-1.1.10.3.34.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to set the struct tm from</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>tm</p></td>
<td class="parameter_description">
<p>struct tm to fill</p>
<p>Passed as <code class="code">tm</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.35"></a><h3>valid?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:valid? self))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the <span class="type">GDate</span> represents an existing day. The date must not
contain garbage; it should have been initialized with <code class="function">g_date_clear()</code>
if it wasn't allocated by one of the <code class="function">g_date_new()</code> variants.</p>
<div class="refsect3">
<a name="id-1.1.10.3.35.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>a <span class="type">GDate</span> to check</p>
<p>Passed as <code class="code">self</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.36"></a><h3>date:new-julian</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:new-julian julian-day))
</pre></div>
<p>Undocumented</p>
<div class="refsect3">
<a name="id-1.1.10.3.36.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>julian_day</p></td>
<td class="parameter_description">
<p></p>
<p>Passed as <code class="code">julian-day</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.37"></a><h3>date:new-dmy</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:new-dmy day month year))
</pre></div>
<p>Undocumented</p>
<div class="refsect3">
<a name="id-1.1.10.3.37.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>day</p></td>
<td class="parameter_description">
<p></p>
<p>Passed as <code class="code">day</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>month</p></td>
<td class="parameter_description">
<p></p>
<p>Passed as <code class="code">month</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>year</p></td>
<td class="parameter_description">
<p></p>
<p>Passed as <code class="code">year</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.38"></a><h3>date:new</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:new))
</pre></div>
<p>Undocumented</p>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.39"></a><h3>date:get-days-in-month</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-days-in-month month year))
</pre></div>
<p>Returns the number of days in a month, taking leap
years into account.</p>
<div class="refsect3">
<a name="id-1.1.10.3.39.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>month</p></td>
<td class="parameter_description">
<p>month</p>
<p>Passed as <code class="code">month</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>year</p></td>
<td class="parameter_description">
<p>year</p>
<p>Passed as <code class="code">year</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.40"></a><h3>date:get-monday-weeks-in-year</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-monday-weeks-in-year year))
</pre></div>
<p>Returns the number of weeks in the year, where weeks
are taken to start on Monday. Will be 52 or 53. The
date must be valid. (Years always have 52 7-day periods,
plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many
Mondays are in the year, i.e. there are 53 Mondays if
one of the extra days happens to be a Monday.)</p>
<div class="refsect3">
<a name="id-1.1.10.3.40.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>year</p></td>
<td class="parameter_description">
<p>a year</p>
<p>Passed as <code class="code">year</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.41"></a><h3>date:get-sunday-weeks-in-year</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:get-sunday-weeks-in-year year))
</pre></div>
<p>Returns the number of weeks in the year, where weeks
are taken to start on Sunday. Will be 52 or 53. The
date must be valid. (Years always have 52 7-day periods,
plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many
Sundays are in the year, i.e. there are 53 Sundays if
one of the extra days happens to be a Sunday.)</p>
<div class="refsect3">
<a name="id-1.1.10.3.41.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>year</p></td>
<td class="parameter_description">
<p>year to count weeks in</p>
<p>Passed as <code class="code">year</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.42"></a><h3>date:is-leap-year?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:is-leap-year? year))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the year is a leap year.
</p>
<p>For the purposes of this function, leap year is every year
divisible by 4 unless that year is divisible by 100. If it
is divisible by 100 it would be a leap year only if that year
is also divisible by 400.</p>
<div class="refsect3">
<a name="id-1.1.10.3.42.5"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>year</p></td>
<td class="parameter_description">
<p>year to check</p>
<p>Passed as <code class="code">year</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.43"></a><h3>date:strftime</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:strftime s slen format date))
</pre></div>
<p>Generates a printed representation of the date, in a
[locale][setlocale]-specific way.
Works just like the platform's C library <code class="function">strftime()</code> function,
but only accepts date-related formats; time-related formats
give undefined results. Date must be valid. Unlike <code class="function">strftime()</code>
(which uses the locale encoding), works on a UTF-8 format
string and stores a UTF-8 result.
</p>
<p>This function does not provide any conversion specifiers in
addition to those implemented by the platform's C library.
For example, don't expect that using <code class="function">g_date_strftime()</code> would
make the \%F provided by the C99 <code class="function">strftime()</code> work on Windows
where the C library only complies to C89.</p>
<div class="refsect3">
<a name="id-1.1.10.3.43.5"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>s</p></td>
<td class="parameter_description">
<p>destination buffer</p>
<p>Passed as <code class="code">s</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>slen</p></td>
<td class="parameter_description">
<p>buffer size</p>
<p>Passed as <code class="code">slen</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>format</p></td>
<td class="parameter_description">
<p>format string</p>
<p>Passed as <code class="code">format</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>date</p></td>
<td class="parameter_description">
<p>valid <span class="type">GDate</span></p>
<p>Passed as <code class="code">date</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.44"></a><h3>date:valid-day?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:valid-day? day))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the day of the month is valid (a day is valid if it's
between 1 and 31 inclusive).</p>
<div class="refsect3">
<a name="id-1.1.10.3.44.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>day</p></td>
<td class="parameter_description">
<p>day to check</p>
<p>Passed as <code class="code">day</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.45"></a><h3>date:valid-dmy?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:valid-dmy? day month year))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the day-month-year triplet forms a valid, existing day
in the range of days <span class="type">GDate</span> understands (Year 1 or later, no more than
a few thousand years in the future).</p>
<div class="refsect3">
<a name="id-1.1.10.3.45.4"></a><h4>Parameters</h4>
<div class="informaltable"><table>
<tr>
<td class="parameter_name"><p>day</p></td>
<td class="parameter_description">
<p>day</p>
<p>Passed as <code class="code">day</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>month</p></td>
<td class="parameter_description">
<p>month</p>
<p>Passed as <code class="code">month</code></p>
</td>
</tr>
<tr>
<td class="parameter_name"><p>year</p></td>
<td class="parameter_description">
<p>year</p>
<p>Passed as <code class="code">year</code></p>
</td>
</tr>
</table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.46"></a><h3>date:valid-julian?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:valid-julian? julian-date))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the Julian day is valid. Anything greater than zero
is basically a valid Julian, though there is a 32-bit limit.</p>
<div class="refsect3">
<a name="id-1.1.10.3.46.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>julian_date</p></td>
<td class="parameter_description">
<p>Julian day to check</p>
<p>Passed as <code class="code">julian-date</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.47"></a><h3>date:valid-month?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:valid-month? month))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the month value is valid. The 12 <span class="type">GDateMonth</span>
enumeration values are the only valid months.</p>
<div class="refsect3">
<a name="id-1.1.10.3.47.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>month</p></td>
<td class="parameter_description">
<p>month</p>
<p>Passed as <code class="code">month</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.48"></a><h3>date:valid-weekday?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:valid-weekday? weekday))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the weekday is valid. The seven <span class="type">GDateWeekday</span> enumeration
values are the only valid weekdays.</p>
<div class="refsect3">
<a name="id-1.1.10.3.48.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>weekday</p></td>
<td class="parameter_description">
<p>weekday</p>
<p>Passed as <code class="code">weekday</code></p>
</td>
</tr></table></div>
</div>
</div>
<div class="refsect2">
<a name="id-1.1.10.3.49"></a><h3>date:valid-year?</h3>
<div class="informalexample"><pre class="programlisting">(define-values (%return) (date:valid-year? year))
</pre></div>
<p>Returns <code class="constant">TRUE</code> if the year is valid. Any year greater than 0 is valid,
though there is a 16-bit limit to what <span class="type">GDate</span> will understand.</p>
<div class="refsect3">
<a name="id-1.1.10.3.49.4"></a><h4>Parameters</h4>
<div class="informaltable"><table><tr>
<td class="parameter_name"><p>year</p></td>
<td class="parameter_description">
<p>year</p>
<p>Passed as <code class="code">year</code></p>
</td>
</tr></table></div>
</div>
</div>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.33.1</div>
</body>
</html>
